<?php

class Core_Model_DbTable_CargoDocuments extends Zend_Db_Table_Abstract {

    protected $_name = 'cargo_documents';
    public function getCargoPicture($id = -1) {
        if($id == -1) {
            return null;
        }

        $cond[] = $this->getAdapter()->quoteInto("cargo_operation_id = (?)", $id);
        $cond[] = $this->getAdapter()->quoteInto('type = (?)', "picture");
        $pictures = $this->fetchAll($cond)->toArray();
        foreach ($pictures as &$picture) {
            $splits = explode("/", $picture['file']);
            $picture_name = end($splits);
            $picture['name'] = $picture_name;
        }
        return $pictures;
    }

    public function getCargoVideo($id = -1) {
        if($id == -1) {
            return null;
        }

        $cond[] = $this->getAdapter()->quoteInto("cargo_operation_id = (?)", $id);
        $cond[] = $this->getAdapter()->quoteInto('type = (?)', "video");
        $videos = $this->fetchAll($cond)->toArray();
        foreach ($videos as &$video) {
            $splits = explode("/", $video['file']);
            $video_name = end($splits);
            $video['name'] = $video_name;
        }
        return $videos;

    }
}

?>
